home *** CD-ROM | disk | FTP | other *** search
- (* Chapter 6 - Program 1 *)
- MODULE Arrays;
-
- FROM InOut IMPORT WriteString, WriteCard, WriteLn;
-
- VAR Index : CARDINAL;
- Automobiles : ARRAY [1..12] OF CARDINAL;
-
- BEGIN (* main program *)
- FOR Index := 1 TO 12 DO
- Automobiles[Index] := Index + 10;
- END;
- Automobiles[7] := 54; (* example, change one value of array *)
- WriteString("This is the first program with an array.");
- WriteLn;
- WriteLn; (* end of data initialization *)
-
- FOR Index := 1 TO 12 DO (* display the data now *)
- WriteString("Automobile number");
- WriteCard(Index,3);
- WriteString(" has the value of");
- WriteCard(Automobiles[Index],3);
- WriteLn;
- END;
- END Arrays.
-
-
-
-
- (* Result of execution
-
- This is the first example program with an array.
-
- Automobile number 1 has the value of 11
- Automobile number 2 has the value of 12
- Automobile number 3 has the value of 13
- Automobile number 4 has the value of 14
- Automobile number 5 has the value of 15
- Automobile number 6 has the value of 16
- Automobile number 7 has the value of 54
- Automobile number 8 has the value of 18
- Automobile number 9 has the value of 19
- Automobile number 10 has the value of 20
- Automobile number 11 has the value of 21
- Automobile number 12 has the value of 22
-
- *)
-